#!/usr/bin/env node

const Koa = require('koa');

const app = new Koa();

app.use((ctx,next)=>{     //M-logger
  console.log(`${ctx.method} ${ctx.path}`);

  next();

  console.log(`cost:${ctx.cost}ms`);
});

app.use((ctx,next)=>{     //m-ms
  const start = Date.now();

  //console.time('cost');

  next();

  //console.timeEnd('cost');

  const end = Date.now();

  ctx.cost = end-start;
});

app.use((ctx,next)=>{     //M-hello
  ctx.body = 'hello world';
});



app.listen(8080);
